-
Notifications
You must be signed in to change notification settings - Fork 565
fix(ai): add message truncation to openai–agents #4968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(ai): add message truncation to openai–agents #4968
Conversation
| SPANDATA.GEN_AI_REQUEST_MESSAGES, | ||
| messages_data, | ||
| unpack=False, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Data Normalization in Agent Span
The invoke_agent_span function is missing a call to _normalize_data() before passing normalized_messages to truncate_and_annotate_messages(). This differs from utils.py and means the truncation function receives Python objects instead of the expected serialized data, preventing it from working correctly. _normalize_data also needs to be imported.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4968 +/- ##
==========================================
- Coverage 83.96% 83.94% -0.03%
==========================================
Files 165 178 +13
Lines 17073 17842 +769
Branches 2999 3172 +173
==========================================
+ Hits 14336 14978 +642
- Misses 1839 1900 +61
- Partials 898 964 +66
|
| # Just verify that messages are being set and truncation is applied | ||
| # The actual truncation behavior is tested in the ai_monitoring tests | ||
| ai_client_span = ai_client_spans[0] | ||
| if "gen_ai.request.messages" in ai_client_span["data"]: | ||
| messages_data = ai_client_span["data"]["gen_ai.request.messages"] | ||
| assert isinstance(messages_data, str) | ||
|
|
||
| parsed_messages = json.loads(messages_data) | ||
| assert isinstance(parsed_messages, list) | ||
| # Verify messages were processed | ||
| assert len(parsed_messages) >= 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this checking that truncation is applied?
I would have thought len(parsed_messages) >= 1 is always true, even without truncation.
Closes TET-1208